/**
 * Created by HUANGFR2 on 8/21/2016.
 */
var app = angular.module('admin' , ['ngRoute', 'ngAnimate', 'ui.bootstrap', 'audit_merchant', 'audit_dish', 'order_complaint']);

app.config(function($routeProvider){
    console.log('router init');
    $routeProvider
        .when('/', {
            redirectTo : '/audit_merchant'
        })
        .when('/audit_merchant',{
            templateUrl : '/client/pages/audit_merchant.html',
            //controller : audit_merchantController
        })
        .when('/audit_dish', {
            templateUrl : '/client/pages/audit_dish.html',
            //controller : audit_dishController
        })
        .when('/low_grade', {
            templateUrl : '/client/pages/low_merchant.html',
            //controller : low_gradeController
        })
        .when('/order_complaint', {
            templateUrl : '/client/pages/order_complaint.html',
            //controller : order_complaintController
        })
        .otherwise({
            redirectTo : '/audit_merchant'
        })
});

app.animation('.view-slide-in', function () {
    return {
        enter: function(element, done) {
            element.css({
                    opacity: 0.5,
                    position: "relative",
                    top: "10px",
                    left: "20px"
                })
                .animate({
                    top: 0,
                    left: 0,
                    opacity: 1
                }, 1000, done);
        }
    };
});

app.animation('.repeat-animation', function () {
    return {
        enter : function(element, done) {
            console.log("entering...");
            var width = element.width();
            element.css({
                position: 'relative',
                left: -10,
                opacity: 0
            });
            element.animate({
                left: 0,
                opacity: 1
            }, done);
        },
        leave : function(element, done) {
            element.css({
                position: 'relative',
                left: 0,
                opacity: 1
            });
            element.animate({
                left: -10,
                opacity: 0
            }, done);
        },
        move : function(element, done) {
            element.css({
                left: "2px",
                opacity: 0.5
            });
            element.animate({
                left: "0px",
                opacity: 1
            }, done);
        }
    };
});